We use the following libraires below:
library(knitr)# enables better documentation
library(tidyverse)# enables us to have data more usable
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.3 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(janitor)# enables us to clean data
##
## Attaching package: 'janitor'
##
## The following objects are masked from 'package:stats':
##
## chisq.test, fisher.test
library(lubridate) # enable us to use the date-time system
library(here) # enables ease of retrieval of files of within a directory
## here() starts at C:/Users/jethu/Documents/R Studio - Stat 383/Lecture Code/DS241Portfolioz
library(sf) # enables us to use spatial data
## Warning: package 'sf' was built under R version 4.3.2
## Linking to GEOS 3.11.2, GDAL 3.7.2, PROJ 9.3.0; sf_use_s2() is TRUE
library(tmap)# enables us to us to visualize the spatial data
## Warning: package 'tmap' was built under R version 4.3.2
## Breaking News: tmap 3.x is retiring. Please test v4, e.g. with
## remotes::install_github('r-tmap/tmap')
library(tidycensus)# enables us to use U.S Census data
## Warning: package 'tidycensus' was built under R version 4.3.2
We read in the needed data based on the D.C capital bikeshare program,the museums in the D.C area, parks and recreational facilities in the D.C area, and bike racs near the recreational areas. We then view them
bykes = (read.csv(here("data_raw","202309-capitalbikeshare-tripdata.csv"))) |> clean_names()
Parks_N_Recs <- st_read(here("data_raw","Parks_and_Recreation_Areas.geojson")) |> clean_names()
## Reading layer `Parks_and_Recreation_Areas' from data source
## `C:\Users\jethu\Documents\R Studio - Stat 383\Lecture Code\DS241Portfolioz\data_raw\Parks_and_Recreation_Areas.geojson'
## using driver `GeoJSON'
## Simple feature collection with 256 features and 56 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -77.11113 ymin: 38.81718 xmax: -76.91108 ymax: 38.98811
## Geodetic CRS: WGS 84
Museuems <- st_read(here("data_raw","Museums.geojson")) |> clean_names()
## Reading layer `Museums' from data source
## `C:\Users\jethu\Documents\R Studio - Stat 383\Lecture Code\DS241Portfolioz\data_raw\Museums.geojson'
## using driver `GeoJSON'
## Simple feature collection with 168 features and 23 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -77.09909 ymin: 38.85658 xmax: -76.95544 ymax: 38.95996
## Geodetic CRS: WGS 84
bracks <- st_read(here("data_raw","Public_Bike_Racks.geojson")) |> clean_names()
## Reading layer `Public_Bike_Racks' from data source
## `C:\Users\jethu\Documents\R Studio - Stat 383\Lecture Code\DS241Portfolioz\data_raw\Public_Bike_Racks.geojson'
## using driver `GeoJSON'
## Simple feature collection with 3557 features and 2 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -77.1107 ymin: 38.81903 xmax: -76.91907 ymax: 38.98663
## Geodetic CRS: WGS 84
view(Parks_N_Recs)
view(Museuems)
view(bracks)
Limit the number of sample size to 100
bykes_sliced <- bykes|> slice_sample(n=100)
view(bykes_sliced)
Read census api key, and view 2018 census variables
We want to access specific census data from 2018
v2018 <- load_variables(2018,"acs5")
We want to gain information from the census data based on the variables vehicles, population, and public_population
df_census <- get_acs(geography = "tract",
variables = c("vehicles"="B08141_001",
"population"="B01001_001",
"public_transportation" = "B08006_008"),
state ="DC",geometry = TRUE,year = 2021)
## Getting data from the 2017-2021 5-year ACS
## Warning: • You have not set a Census API key. Users without a key are limited to 500
## queries per day and may experience performance limitations.
## ℹ For best results, get a Census API key at
## http://api.census.gov/data/key_signup.html and then supply the key to the
## `census_api_key()` function to use it throughout your tidycensus session.
## This warning is displayed once per session.
## Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
##
|
| | 0%
|
|========================= | 36%
|
|==================================================== | 74%
|
|========================================================= | 81%
|
|======================================================================| 100%
Mini plots of census,parks n recs, mususems and bike racks data which we generate
plot(df_census)
plot(Parks_N_Recs)
## Warning: plotting the first 9 out of 56 attributes; use max.plot = 56 to plot
## all
plot(Museuems)
## Warning: plotting the first 9 out of 23 attributes; use max.plot = 23 to plot
## all
plot(bracks)
we specefically look public transportation, and vehicle density within
the D.C area
tmap_mode("view")
## tmap mode set to interactive viewing
df_census_Pop = df_census %>%
select(-moe) %>%
pivot_wider(names_from = "variable",
values_from = "estimate")|>
mutate(pub_pop = public_transportation / population, v_pop = vehicles / population)
We create the vizulation of the musemums,parks and recreational facilities in the D.C area, see the amount of bike racks near said locations, and see the vehicle, and public transporation density based on the population that use these modes of transport
df_census_adjust = df_census |> st_transform(4326)
Parks_N_Recs = st_as_sf(Parks_N_Recs,crs = st_crs(df_census_adjust))
bracks = st_as_sf(bracks,crs=st_crs(df_census_adjust))
museums = st_as_sf(Museuems,crs=st_crs(df_census_adjust))
tm_shape(df_census_Pop) + tm_polygons(c("pub_pop","v_pop"),alpha = .5) + tm_shape(Parks_N_Recs)+
tm_symbols(col = "green", size=0.08,alpha = 0.5) + tm_shape(museums)+ tm_symbols(col = "violet",
size=0.08,alpha = 0.5) + tm_shape(bracks)+ tm_dots(col = "red", size=0.004,alpha = 0.5)
We see in the map above that, the visualization made depicts areas where recreation and parks in the D.C area exist in green orbs, museums in purple orbs, and the various bike rack locations in the entire D.C area in the form of red dots.
Though we can see a majority of bike rack around the D.C area, and mostly in the center area of D.C, which surround areas which have museums, recreation and park facilities. But we do see some patches within the map, where the population of people who tend to drive, and use public transportation, have slightly lesser amounts of bike racks near the Museums recreational and park facilities, which are near the outskirts of town, which was an odd site to see.
Based On this analysis, the perception given is that the ability to access some museum, recreation and park areas, can be quite difficult if one does not own a car, due to the lack of public transportation in said areas, this is where the DC bike share program make an entrance with a solution, I believe allocating more bike racks across museum, recreation and park facility areas, could possibly be a positive renforcement to get more people to ride bikes to and from such areas, which could in-return drive an increase in economic revenue growth, of the D.C government.
Another reason would be to promote, and draw awareness to healthy recreational bike rides within youth (and possibly the elderly), As according to an observational-study article dubbed “Cycling as a Part of Recreation: An Awareness-Exploring Study” recreational bike rides could lead to mental, and physical health benefits within society, but much work is needed to be done, and this starts with the allocation of an adequate amount bike racks within the various recreational and park areas, which lack them.
#Data Refernced
Parks and recreations: https://opendata.dc.gov/datasets/DCGIS::parks-and-recreation-areas/explore?location=38.898985%2C-76.948888%2C12.49
Bike Racks: https://opendata.dc.gov/datasets/public-bike-racks/explore
dc_bikeshare: https://opendata.dc.gov/datasets/a1f7acf65795451d89f0a38565a975b3_5/about
Article: Uca, M., Alizadehebadi, L. and Yılmaz, S.H. (2021) ‘Cycling as a part of recreation: An awareness-exploring study’, Journal of Educational Issues, 7(3), p. 265. doi:10.5296/jei.v7i3.19152.